TWB.New_Module({
	///////////////////////////
	name : "Filter",		 //
	author : "enduo",        //
	version : 1.0,           //
	///////////////////////////
	
	Set : function(param){
		var A=TWB.gei("TWB-Filter-Normal");
		var B=TWB.gei("TWB-Filter-Offensive");
		var C=TWB.gei("TWB-Filter-Defensive");
		A.style.color=B.style.color=C.style.color="black";
		switch(param){
			case 'normal' :
				A.style.color="blue";
			break;
			
			case 'offensive' :
				B.style.color="blue";
			break;
			
			case 'defensive' :
				C.style.color="blue";
			break;
		}
	},
	BackD : function(){
		var i;
		var vil;
		var flag=false;
		var V=TWB.gei("TWB-VillageList").childNodes;
		var cvil=TWB.Modules.BackNext.GetVil();
		for(i=0; i<V.length; i++){
			if(V[i].getAttribute("id").replace("TWB-v","")==cvil){
				break;
			}
		}
		i--;
		while(i>=0){
			vil=V[i].getAttribute("id").replace("TWB-v","");
			if(typeof TWB._SESSION.UNITS[vil]!="undefined"){
				if(!TWB.Modules.Villages.IsOffensive(vil)){
					flag=true;
					TWB.Modules.BackNext.LoadVil(vil);
					break;
				}
			}
			i--;
		}
		if(!flag){
			alert(TWB.lang("startvil"));
		}
	},
	NextD : function(){
		var i;
		var vil;
		var flag=false;
		var V=TWB.gei("TWB-VillageList").childNodes;
		var cvil=TWB.Modules.BackNext.GetVil();
		for(i=0; i<V.length; i++){
			if(V[i].getAttribute("id").replace("TWB-v","")==cvil){
				break;
			}
		}
		i++;
		while(i<V.length){
			vil=V[i].getAttribute("id").replace("TWB-v","");
			if(typeof TWB._SESSION.UNITS[vil]!="undefined"){
				if(!TWB.Modules.Villages.IsOffensive(vil)){
					flag=true;
					TWB.Modules.BackNext.LoadVil(vil);
					break;
				}
			}
			i++;
		}
		if(!flag){
			alert(TWB.lang("endvil"));
		}
	},
	BackO : function(){
		var i;
		var vil;
		var flag=false;
		var V=TWB.gei("TWB-VillageList").childNodes;
		var cvil=TWB.Modules.BackNext.GetVil();
		for(i=0; i<V.length; i++){
			if(V[i].getAttribute("id").replace("TWB-v","")==cvil){
				break;
			}
		}
		i--;
		while(i>=0){
			vil=V[i].getAttribute("id").replace("TWB-v","");
			if(typeof TWB._SESSION.UNITS[vil]!="undefined"){
				if(TWB.Modules.Villages.IsOffensive(vil)){
					flag=true;
					TWB.Modules.BackNext.LoadVil(vil);
					break;
				}
			}
			i--;
		}
		if(!flag){
			alert(TWB.lang("startvil"));
		}
	},
	NextO : function(){
		var i;
		var vil;
		var flag=false;
		var V=TWB.gei("TWB-VillageList").childNodes;
		var cvil=TWB.Modules.BackNext.GetVil();
		for(i=0; i<V.length; i++){
			if(V[i].getAttribute("id").replace("TWB-v","")==cvil){
				break;
			}
		}
		i++;
		while(i<V.length){
			vil=V[i].getAttribute("id").replace("TWB-v","");
			if(typeof TWB._SESSION.UNITS[vil]!="undefined"){
				if(TWB.Modules.Villages.IsOffensive(vil)){
					flag=true;
					TWB.Modules.BackNext.LoadVil(vil);
					break;
				}
			}
			i++;
		}
		if(!flag){
			alert(TWB.lang("endvil"));
		}
	}
});